<?php
    require_once ("Includes/session.php");
    require_once ("Includes/simplecms-config.php"); 
    require_once ("Includes/connectDB.php");
    require_once("conf.php");   
    include("Includes/header.php"); 
    if (!logged_on())
    {
        header ("Location: logon.php");
    }

    $val = trim($_SERVER['QUERY_STRING']);
    if(empty($val))
    {
        header ("Location: Student_ExamSelection.php");
    }
    else
    {
        $temp =explode('=', $val);
        $_SESSION['attemptID'] =  $temp[1];
    }

?>

        <div id="fullmain">
            <h2>Exam History</h2>   
            <?php
            $dg = new C_DataGrid("SELECT * FROM answers 
            INNER JOIN exam_attempts on exam_attempts.id = answers.exam_attempt_id 
            INNER JOIN questions on answers.question_id = questions.id", "id", "exam_attempts");
            $dg -> set_query_filter("user_id = ".$_SESSION['userid']);
            $dg -> set_query_filter("exam_attempt_id = ".$_SESSION['attemptID']);
            $dg -> set_dimension(600, 500); 
            $dg -> set_col_hidden("id");
            $dg -> set_col_hidden("user_id");
            $dg -> set_col_hidden("exam_id");
            $dg -> set_col_hidden("C1");
            $dg -> set_col_hidden("C2");
            $dg -> set_col_hidden("C3");
            $dg -> set_col_hidden("C4");
            $dg -> set_col_hidden("mark");
            $dg -> set_col_hidden("question_id");
            $dg -> set_col_hidden("exam_attempt_id");
            $dg -> set_col_title("AIndex", "Correct Answer");
            $dg -> set_col_title("title", "Exam");
            $dg -> set_col_title("anstime", "Date");
            $dg -> enable_export('PDF');
            $dg -> enable_export('EXCEL');
            $dg -> enable_search(true);
            $dg -> enable_advanced_search(true);
            $onSelectRow = <<<ONSELECTROW
            function(status, rowid)
            {
               // window.location = "Student_DoExam.php?id=" + rowid;
	            //alert(rowid);
            }
ONSELECTROW;


                //$dg->add_event("jqGridSelectRow", $onSelectRow);
                $dg -> add_event("jqGridDblClickRow", $onSelectRow);
                $dg -> display();
            ?>
        </div>
</div>

<?php include ("Includes/footer.php"); ?>